<template>

  <!--开始必须新建一个div根目录-->
  <div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td>标题</td>
        <td>内容</td>
        <td>操作</td>
      </tr>
      <tr v-for="i in list">
        <td>{{i.title}}</td>
        <td>{{i.content}}</td>
        <td>
          <button @click="users(i.id)">查看</button></td>
      </tr>
    </table>

  </div>
</template>

<script>
export default {
  name: "news",
  data() {
    return {
      list:[],
    }
  },

  methods: {
    get_news(){
      this.$axios.get('users/newss/')
      .then(res=>{
        this.list = res.data.list
      })
    },
    users(id){
        let userid = localStorage.getItem('puserid')
        if (userid){
          this.$router.push({'path':'sq',query:{id:id}})
          .then(res=>{
            // if(res.data.code==10011){
            //   alert("您只有三次访问机会")
            // }
          })
        }else{
          this.$router.push({"path":"log"})
        }
    },
  },

  computed: {},

  mounted() {
    this.get_news()
  }
}
</script>

<style scoped>

</style>
